package com.cryptoneedle.garden.vo;


import com.cryptoneedle.garden.enums.JoinType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.List;

/**
 * <p>description: 标准表配置 </p>
 *
 * @author CryptoNeedle
 * @date 2025-09-26
 */
@Data
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
public class JoinTableConfigVo {

    @NotBlank(message = "主目录名称不能为空")
    @Schema(description = "主目录名称")
    private String primaryCatalogName;

    @NotBlank(message = "主库名称不能为空")
    @Schema(description = "主库名称")
    private String primaryDatabaseName;

    @NotBlank(message = "主表名称不能为空")
    @Schema(description = "主表名称")
    private String primaryTableName;

    @NotEmpty(message = "关联表配置不能为空")
    @Schema(description = "关联表配置")
    private List<JoinTableConfigs> joinTableConfigs;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Accessors(chain = true)
    @ToString
    public static class JoinTableConfigs {

        @NotBlank(message = "关联类型不能为空")
        @Schema(description = "关联类型")
        private JoinType joinType;

        @NotBlank(message = "关联目录名称不能为空")
        @Schema(description = "关联目录名称")
        private String joinCatalogName;

        @NotBlank(message = "关联库名称不能为空")
        @Schema(description = "关联库名称")
        private String joinDatabaseName;

        @NotBlank(message = "关联表名称不能为空")
        @Schema(description = "关联表名称")
        private String joinTableName;

        @NotEmpty(message = "关联字段配置不能为空")
        @Schema(description = "关联字段配置")
        private List<JoinColumnConfig> joinColumnConfigs;

        @Data
        @NoArgsConstructor
        @AllArgsConstructor
        @Accessors(chain = true)
        @ToString
        public static class JoinColumnConfig {

            @NotBlank(message = "主表列名称不能为空")
            @Schema(description = "主表列名称")
            private String primaryColumnName;

            @NotBlank(message = "关联表列名称不能为空")
            @Schema(description = "关联表列名称")
            private String joinColumnName;
        }
    }
}